package com.xqc.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xqc.mode.TRole;
import com.xqc.service.TRoleService;

/**
* @author 作者 Gavin.Dai/SNSSZ00036
* @dateTime 创建时间：2020年8月18日 下午3:36:24
* @version V1.0.0
* 类说明
*/
@RestController
@RequestMapping("/role")
public class TRoleController {

	@Autowired
	private TRoleService tRoleService;
	
	@GetMapping("/add")
	public String add(){
	boolean result = true;
	for (int i = 0; i < 5; i++) {
		TRole role = new TRole();
		role.setRoleName("张三"+i);
		 result = this.tRoleService.insert(role);
	}
		if(result){
			return "success";
		}
		return "fail";
	}
	
	@GetMapping("/selectAll")
	public List<TRole> selectAll(){
		return this.tRoleService.selectAll();
	}
	
	
	@GetMapping("/selectByRoleIds")
	public List<TRole> selectByRoleIds(){
		List<Long> userIds = new ArrayList<>();
		userIds.add(505499176348418048L);
		userIds.add(505499175908016129L);
		return this.tRoleService.selectByRoleIds(userIds);
	}
	
	@GetMapping("/updateByModel")
	public boolean  updateByModel(){
		TRole tRole = new TRole();
		tRole.setId(505502157085081600L);
		tRole.setRoleName("TTTTTTT");
		return this.tRoleService.updateByModel(tRole);
	}
	
}
